package com.example.controller.aboutCollege;

import com.example.vo.request.SaveCollegeEnrollData;
import com.example.permission.PermissionCheck;
import com.example.service.aboutCollege.CollegeEnrollmentService;
import com.example.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/college")
public class CollegeEnrollmentController {

    @Resource
    private CollegeEnrollmentService collegeEnrollmentService;

    @PostMapping("/saveCollegeEnrollData")
    @PermissionCheck(permissionPath = "/collegeEnrollment/createCollegeEnrollmentData")
    public Result saveCollegeEnrollData(@RequestBody List<SaveCollegeEnrollData> collegeEnrollData) {
        return collegeEnrollmentService.saveCollegeEnrollData(collegeEnrollData);
    }

    @GetMapping("/collegeData/{collegeName}")
    @PermissionCheck(permissionPath = "/collegeEnrollment")
    public Result getCollegeData(@PathVariable String collegeName) {
        return collegeEnrollmentService.getCollegeData(collegeName);
    }

    @GetMapping("/deleteCollegeData/{collegeEnrollId}")
    @PermissionCheck(permissionPath = "/collegeEnrollment/operateCollegeEnrollment")
    public Result deleteCollegeData(@PathVariable Integer collegeEnrollId) {
        return collegeEnrollmentService.deleteCollegeData(collegeEnrollId);
    }

    @GetMapping("/updateCollegeData/{collegeName}/{grade}")
    public Result updateCollegeData(@PathVariable String collegeName, @PathVariable String grade) {
        return collegeEnrollmentService.updateCollegeData(collegeName, grade);
    }

    @GetMapping("/collegeMajorData/{major}")
    @PermissionCheck(permissionPath = "/collegeEnrollment")
    public Result getCollegeMajorData(@PathVariable String major) {
        return collegeEnrollmentService.getCollegeMajorData(major);
    }
}
